package com.example.sun.myapplication.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ListView;

import com.example.sun.myapplication.R;
import com.example.sun.myapplication.bean.WeChatMessageBean;
import com.example.sun.myapplication.adapter.CommonAdapter;
import com.example.sun.myapplication.adapter.ViewHolder;
import com.example.sun.myapplication.adapter.WeChatAdapter;
import com.example.sun.myapplication.fragment.MyFragment;

import java.util.ArrayList;
import java.util.List;

public class WeChatActivity extends FragmentActivity {

    public static final String TAG = WeChatActivity.class.getSimpleName();

    private MyFragment myFragment;

    FragmentManager manager;
    FragmentTransaction transaction;

    // 页面初始化时调用，如果页面没销毁，再次显示该页面时不会再次调用此方法
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 加载布局
        setContentView(R.layout.activity_wechat);

        manager = getSupportFragmentManager();

        transaction = manager.beginTransaction();

        myFragment = new MyFragment();

        // add和replace操作是走生命周期的
        transaction.add(R.id.fragment_content, myFragment);
        transaction.replace(R.id.fragment_content, myFragment);

        // hide和show是不走生命周期的
        transaction.hide(myFragment);
        transaction.show(myFragment);

        transaction.commit();
    }

    // 页面显示（处于栈顶）时会调用此方法
    @Override
    protected void onResume() {
        super.onResume();
    }

}
